package com.neutech.neusys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neutech.neusys.mapper.ConstantItemMapper;
import com.neutech.neusys.mapper.DeptMapper;
import com.neutech.neusys.mapper.RegistLevelMapper;
import com.neutech.neusys.mapper.UserMapper;
import com.neutech.neusys.service.UserService;
import com.neutech.po.ConstantItem;
import com.neutech.po.Dept;
import com.neutech.po.RegistLevel;
import com.neutech.po.User;
import com.neutech.vo.ToAddUserVo;

@Service
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userMapper;
	@Autowired
	private DeptMapper deptMapper;
	@Autowired
	private RegistLevelMapper registLevelMapper;
	@Autowired
	private ConstantItemMapper constantItemMapper;
	/**
	 * 增加用户
	 * @param:用户对象
	 * @return:添加成功==1，添加失败==0
	 * */
	@Override
	public int addUser(User user) {
		// TODO Auto-generated method stub
		int num = userMapper.addUser(user);
		return num;
	}
	
	/**
	 * 增加科室
	 * @return:添加成功==1，添加失败==0
	 * */
	@Override
	public int addDept(Dept dept) {
		// TODO Auto-generated method stub
		int num = deptMapper.addDept(dept);
		return num;
	}
	
	/**
	 * 编辑科室
	 * @return:编辑成功==1，编辑失败==0
	 * */
	@Override
	public int updateDept(Dept dept) {
		// TODO Auto-generated method stub
		int num = deptMapper.updateDept(dept);
		return num;
	}
	
	/**
	 * 删除科室
	 * @return:编辑成功==1，编辑失败==0
	 * */
	@Override
	public int deleteDept(int id) {
		// TODO Auto-generated method stub
		int num = deptMapper.deleteDept(id);
		return num;
	}
	
	/**
	 * 添加用户界面出现前，要查询信息，填充下拉列表
	 * 科室，用户类别，挂号级别，医生职称
	 * @return:添加成功==1，添加失败==0
	 * */
	@Override
	public ToAddUserVo toAddUser() {
		// TODO Auto-generated method stub
		List<Dept> deptList = deptMapper.queryAll();
		List<RegistLevel> regList = registLevelMapper.queryAll();
		List<ConstantItem> conList = constantItemMapper.queryAll();
		List<ConstantItem> conList1 = constantItemMapper.queryAll1();
		List<ConstantItem> conList2 = constantItemMapper.queryAll2();
		ToAddUserVo vo = new ToAddUserVo();
		vo.setDeptList(deptList);
		vo.setRegList(regList);
		vo.setConList(conList);
		vo.setConList1(conList1);
		vo.setConList2(conList2);
 		return vo;
	}

	@Override
	public List<User> queryAllUser() {
		// TODO Auto-generated method stub
		return userMapper.queryAllUser();
	}
}
